<?php

namespace fanletter\manager;

/**
 * 
 * manages the Designs
 * @author Evan
 *
 */
use fanletter\model\Design;

class DesignManager
{
	private static $instance;
	private $designs = array();
	
	private function __construct()
	{
		$designs[Design::DEFAULT_DESIGN_FOLDER] = new Design();
	}
	
	/**
	 * 
	 * @return DesignManager
	 */
	public static function getInstance()
	{
		if (self::instance === NULL)
		{
			self::$instance = new self();
		}
		return self::$instance;
	}
	
	/**
	 * 
	 * Gets the Design-data for a specific named design-folder
	 * Returns default-design if the specified design was not found
	 * 
	 * @param String $design
	 * @return Design
	 */
	public function getDesign($design)
	{
		if (isset($this->designs[$design]))
		{
			return $this->designs[$design];
		}
		
		// TODO: This does not work yet. Where are the designs located? Include it in here. (Configuration File)
		if (file_exists($design))
		{
			$designs[$design] = new Design($design);
			return $this->designs[$design];
		}
		return $this->designs[Design::DEFAULT_DESIGN_FOLDER];
	}
	
}